package com.app.ctzoverseas.network.http

import com.android.base_network.RetrofitClient
import com.cardetective.shopcar.network.api.GoodsApi
import com.cardetective.shopcar.network.api.LoginApi
import com.cardetective.shopcar.network.model.AddCarPost
import com.cardetective.shopcar.network.model.BindMobilePost
import com.cardetective.shopcar.network.model.LoginPost

class GoodsNetwork {

    private val mGoodsApi by lazy { RetrofitClient.getInstance().createApi(GoodsApi::class.java) }

    fun getGoodsCategory(parentId: String) = mGoodsApi.getAllCategory(parentId)
    fun getGoodsList(categoryId: String, page: Int, pageSize: Int) =mGoodsApi.getGoodsList(categoryId, page, pageSize)
    fun getGoodsDetail(goodsId: String) =mGoodsApi.getGoodsDetail(goodsId)
    fun getGoodsBySkuDetail(goodsId: String,goodsSkuId: String) =mGoodsApi.getGoodsBySkuDetail(goodsId, goodsSkuId)
    fun addCar(cartType: String,num: Int,skuId:String) =mGoodsApi.addCar(cartType,num,skuId)
    fun getCarData() =mGoodsApi.getCarData()
    fun checkAllGoodsCar(checked:Boolean) =mGoodsApi.checkAllGoodsCar(checked)
    fun checkedStoreCar(checked:Boolean,storeId:String) =mGoodsApi.checkedStoreCar(checked,storeId)
    fun updateGoodsInCar(num: Int,skuId: String) =mGoodsApi.updateGoodsInCar(num, skuId)
    fun deleteGoodsInCar(skuIds: String) =mGoodsApi.deleteGoodsInCar(skuIds)
    fun submitCarOrder(cartType: String) =mGoodsApi.submitCarOrder(cartType)
    fun checkedSingleGoodInCar(skuId: String,checked: Boolean) =mGoodsApi.checkedSingleGoodInCar(skuId, checked)
    fun calCarGoods(cartType: String) =mGoodsApi.calCarGoods(cartType)
    fun payment(payType: String,sn:String) =mGoodsApi.payment(payType, sn)


    companion object {
        @Volatile
        private var netWork: GoodsNetwork? = null

        fun getInstance() = netWork ?: synchronized(this) {
            netWork ?: GoodsNetwork().also { netWork = it }
        }
    }
}